package com.example.translateappjava.Utils;

import android.os.Parcel;
import android.os.Parcelable;

public class ImageDataLite implements Parcelable {
    private String recognitionResult = "EMPTY";
    private String ImageURL = "NULL";
    private String suggestion = "EMPTY";
    private boolean eatable = true;

    // 构造方法
    public ImageDataLite(String recognitionResult, String imageURL, String suggestion, boolean eatable) {
        this.recognitionResult = recognitionResult;
        this.ImageURL = imageURL;
        this.suggestion = suggestion;
        this.eatable = eatable;
    }

    // 从 ImageData 构造 ImageDataLite
    public ImageDataLite(ImageData imageData) {
        this.recognitionResult = imageData.getRecognitionResult();
        this.ImageURL = imageData.getImageURL();
        this.suggestion = imageData.getSuggestion();
        this.eatable = imageData.isEatable();
    }

    // Parcelable 实现
    protected ImageDataLite(Parcel in) {
        recognitionResult = in.readString();
        ImageURL = in.readString();
        suggestion = in.readString();
        eatable = in.readByte() != 0; // true if byte != 0
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(recognitionResult);
        dest.writeString(ImageURL);
        dest.writeString(suggestion);
        dest.writeByte((byte) (eatable ? 1 : 0));
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<ImageDataLite> CREATOR = new Creator<ImageDataLite>() {
        @Override
        public ImageDataLite createFromParcel(Parcel in) {
            return new ImageDataLite(in);
        }

        @Override
        public ImageDataLite[] newArray(int size) {
            return new ImageDataLite[size];
        }
    };

    // Getter 和 Setter 方法
    public String getRecognitionResult() {
        return recognitionResult;
    }

    public String getImageURL() {
        return ImageURL;
    }

    public String getSuggestion() {
        return suggestion;
    }

    public boolean isEatable() {
        return eatable;
    }

    public void setRecognitionResult(String recognitionResult) {
        this.recognitionResult = recognitionResult;
    }

    public void setImageURL(String imageURL) {
        this.ImageURL = imageURL;
    }

    public void setSuggestion(String suggestion) {
        this.suggestion = suggestion;
    }

    public void setEatable(boolean eatable) {
        this.eatable = eatable;
    }

    @Override
    public String toString() {
        return "ImageDataLite{" +
                "recognitionResult='" + recognitionResult + '\'' +
                ", ImageURL='" + ImageURL + '\'' +
                ", suggestion='" + suggestion + '\'' +
                ", eatable=" + eatable +
                '}';
    }
}
